package com.zbkj.front.controller.user;

import com.zbkj.common.request.MerchantCommunityStatRequest;
import com.zbkj.common.response.*;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.CommunityStatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 小区分红统计 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/front/community/stat")
@Api(tags = "小区分红统计") //配合swagger使用

public class CommunityStatController {

    @Autowired
    private CommunityStatService communityStatService;


    @ApiIgnore
    @ApiOperation(value = "分红统计信息")
    @RequestMapping(value = "/info/old/{merId}", method = RequestMethod.GET)
    public CommonResult<MerchantCommunityStatInfoFrontResponse> getStatInfo(@PathVariable("merId") Integer merId) {
        return CommonResult.success(communityStatService.getMerchantStatInfo(merId));
    }

    @ApiIgnore
    @ApiOperation(value = "分红统计信息-实时")
    @RequestMapping(value = "/infoAcl/{merId}", method = RequestMethod.GET)
    public CommonResult<MerchantCommunityStatInfoFrontResponse> getStatInfoAcl(@PathVariable("merId") Integer merId) {
        return CommonResult.success(communityStatService.getStatInfoActual(merId));
    }

    /**
     * 分红统计信息
     * @author Caiyc
     * @since 2025-07-21
     */
    @ApiOperation(value = "分红统计信息")
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public CommonResult<MerchantCommunityStatInfoFrontResponse> getMerchantStatInfo(@ModelAttribute MerchantCommunityStatRequest request) {
        if (request.getMerId() != null && request.getMerId() > 0) {
            return CommonResult.success(communityStatService.getMerchantStatInfo(request.getMerId()));
        } else {
            return CommonResult.success(communityStatService.getCommunityStat(request.getComId()));
        }
//        return CommonResult.success(communityStatService.getStatInfoActual(merId));
    }

}
